#include <iostream>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <time.h>

//#include <boost/lambda/lambda.hpp>

#include "lambda/lambda.hpp"

using namespace night::lambda;

struct Foo {
	int & sum;
	typedef int result_type;

	Foo ( int & src ) : sum (src) {}
	int operator () (int x) const { return sum += x*x*x; }
};

int main ()
{
	const int dim = 100000;
	const int cnt = 100000;
	(void)cnt;

	std::vector<int> vi (dim);
	for ( int i = 0; i<dim; ++i ) vi[i] = i;

	int s = 0;
	time_t start = time (0);
	for ( int c = 0; c<cnt; ++c ) std::for_each (vi.begin(),vi.end(), Foo (s) );
//	for ( int c = 0; c<cnt; ++c ) std::for_each (vi.begin(),vi.end(), fun (x) [ s += x*x*x ]);
//	for ( int c = 0; c<cnt; ++c ) std::for_each (vi.begin(),vi.end(), boost::lambda::_1*boost::lambda::_1 );

	time_t end = time (0);

	std::cout << "sum=" << s << std::endl << "time:" << difftime(end,start) << std::endl;

}

